package com.lukebang.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.lukebang.util.Base64ImageUtils;
import com.lukebang.util.QINIUUploadUtil;

/**
 * 
 * PictureForController 上午10:53:22
 * 
 * Copyright zhaocj Inc. All rights reserved.
 * Love ME Like Justin Bieber.
 */
@Controller
@RequestMapping("/picture/")
public class PictureForController {
	@RequestMapping("upload")
	public @ResponseBody Map<String, String> insertAlbum(MultipartFile goodImg, HttpSession session) throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		QINIUUploadUtil.uploadByStream(goodImg.getInputStream());
		QINIUUploadUtil.uploadByByte(goodImg.getBytes());
		map.put("success", "成功啦");
		return map;
	}

	@RequestMapping("getImageB64")
	public @ResponseBody String getImageB64(MultipartFile goodImg, HttpSession session) throws Exception {
		return Base64ImageUtils.encodeImgageToBase64(goodImg);
	}
}
